package com.fl.message.mq;

import com.alibaba.fastjson.JSON;
import com.fl.message.entity.UserMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.fl.message.constant.MessageConstant.PUBLIC_EXCHANGE_MESSAGE;
import static com.fl.message.constant.MessageConstant.PUBLIC_KEY_MESSAGE;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: fulin
 * @Date: 2023/01/06/13:33
 * @Description:
 */
@Component
public class RabbitmqSend {


    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendMessage(UserMessage userMessage){
        rabbitTemplate.convertAndSend(PUBLIC_EXCHANGE_MESSAGE, "",JSON.toJSONString(userMessage));
    }
}
